# 判断是否安装了netplan
if ! command -v netplan &> /dev/null
then
  echo "-1"
  exit 0
fi

# 备份/etc/netplan下的所有配置到temp文件夹下
target_dir="/etc/netplan"
confFile=$target_dir/$1
tempDir=$target_dir/temp
## 判断当前是否已经备份过，已经备份则退出
#if [ -d ${tempDir} ]; then
#  if [ ! -f $confFile ]; then
#    netplan get
#    exit 0
#  fi
#  exit 0
#fi

if [ ! -d $tempDir ]; then
    mkdir -p ${tempDir}
fi

if [  -f $target_dir/*.yaml ]; then
  for file in $target_dir/*.yaml; do
    mv $file ${tempDir}
  done
fi
netplan get
exit 0
